package com.bstek.bdf2.core.redis;

import java.util.concurrent.TimeUnit;
import java.util.function.Function;

/**
 * @Title: 入参对象
 * @Package: com.bstek.bdf2.core.redis
 * @Description:
 * @Author: zxq
 * @Date: 2024/1/23 - 21:42
 */
public class InfoBody<ID,R> {
    private String keyPrefix;
    private ID id;
    private Class<R> type;
    Function<ID, R> fallback;
    private Long time;
    private TimeUnit unit;

    public InfoBody() {
    }

    public InfoBody(String keyPrefix, ID id, Class<R> type, Function<ID, R> fallback) {
        this.keyPrefix = keyPrefix;
        this.id = id;
        this.type = type;
        this.fallback = fallback;
    }

    public InfoBody(String keyPrefix, ID id, Class<R> type, Function<ID, R> fallback, Long time, TimeUnit unit) {
        this.keyPrefix = keyPrefix;
        this.id = id;
        this.type = type;
        this.fallback = fallback;
        this.time = time;
        this.unit = unit;
    }

    public String getKeyPrefix() {
        return keyPrefix;
    }

    public void setKeyPrefix(String keyPrefix) {
        this.keyPrefix = keyPrefix;
    }

    public ID getId() {
        return id;
    }

    public void setId(ID id) {
        this.id = id;
    }

    public Class<R> getType() {
        return type;
    }

    public void setType(Class<R> type) {
        this.type = type;
    }

    public Function<ID, R> getFallback() {
        return fallback;
    }

    public void setFallback(Function<ID, R> fallback) {
        this.fallback = fallback;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public TimeUnit getUnit() {
        return unit;
    }

    public void setUnit(TimeUnit unit) {
        this.unit = unit;
    }

    @Override
    public String toString() {
        return "BstekCache{" +
                "keyPrefix='" + keyPrefix + '\'' +
                ", id=" + id +
                ", type=" + type +
                ", fallback=" + fallback +
                ", time=" + time +
                ", unit=" + unit +
                '}';
    }
}
